<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
<!--    <link href="main.css" rel="stylesheet" type="text/css" />-->
    <script src='https://cdn.bootcss.com/socket.io/2.0.3/socket.io.js'></script>
    <script src='//cdn.bootcss.com/jquery/1.11.3/jquery.js'></script>
<!--     <script src='/notify.js'></script>-->
</head>
<body>

<div class="notification sticky hide">
    <p id="content"> </p>
    <a class="close" href="javascript:"></a>
</div>
<div class="wrapper">
    <div style="width:850px;">
        <h3>测试:</h3>
        当前用户uid：<b class="uid">30</b><br>
    </div>

    <script>

        var uid = '30';//ca1158f38ecd7c079e385aa53389f0dc
        var ws =  new WebSocket("ws://39.108.36.131:2348");
        var msg = '{"type":"bind","fromUid":"'+uid+'"}';

        ws.onopen = function(){
            console.log("websocket连接成功");
            ws.send(msg);

        };

        ws.onlogin = function(){
            console.log("loginshijian");
            ws.send('logninnnnn');
        };

        ws.onmessage = function(e){
            console.log("接受到来自服务器端的数据:"+e.data);
            //var message =  eval("("+e.data+")");
            //console.log(message);
        }


        /*ws.onclose = function(e){
            alert('服务器关闭');
        }*/


        // $(document).ready(function () {
        //     // 连接服务端
        //     var socket = io('http://39.108.36.131:2123');

        //     // 连接后登录
        //     socket.on('connect', function(){
        //         socket.emit('login', uid);
        //         //socket.send({name:'tom'});
        //     });

        //     socket.on('message', function(data){
        //         console.log(data);
        //     });

        //     // 后端推送来消息时
        //     socket.on('new_msg', function(msg){
        //         $('#content').html('收到消息1：'+msg);
        //         $('.notification.sticky').notify();
        //     });

        //     // 后端推送来在线数据时
        //     socket.on('update_online_count', function(online_stat){
        //         $('#online_box').html(online_stat);
        //     });

            /*const socket = io('http://39.108.36.131:2123');
            socket.on('connect', function(){
                socket.emit('login', uid);
                socket.send({name:'tom'});
            });
            socket.emit("test", "your message");
            socket.on("test",function(res){
                console.log(res);
            });*/

        //});
    </script>
    <div id="footer">
        <center id="online_box"></center>
        <center><p style="font-size:11px;color:#555;"> Powered by <a href="http://www.workerman.net/web-sender" target="_blank"><strong>web-msg-sender!</strong></a></p></center>
    </div>
</body>
</html>
